<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        console.log(window.history.length);
        window.onload=function()
        {
            var forward=document.querySelector("#forward")
            var back=document.querySelector("#back")
            var go=document.querySelector("#go")
            forward.onclick=function()
            {
                history.forward()  //前进一步
            }
            back.onclick=function()
            {
                history.back() //后退一步
            }
            go.onclick=function()
            {
                history.go(-2)  //后退两步
            }
        }
    </script>
</head>
<body>
    <button id="forward">前进</button>
    <button id="back">后退</button>
    <button id="go">跳转指定步数</button>
</body>
</html>